#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/7/24 18:17
# @Author  : Jet
# @Email   : jyan@abot.cn
# @File    : my_test01.py

# 字典遍历示例

dict1 = {"a":10,"B":20,"C":True,"D":"hello world","e":"python教程"}

dict2 = {key:value for key,value in dict1.items() if key.islower()}
print(dict2)

dict3 = {key:value for key,value in dict1.items() if type(value) is int}
print(dict3)

dict4 = {key:value for key,value in dict1.items() if isinstance(value, (int))}
print(dict4)

print("\r\n")

# 遍历字典的2中方法：
# （1）遍历字典：根据key
for key in dict1:
    print("%s ==>> %s, type value: %s" % (key, dict1[key], type(dict1[key])))

print("\r\n")

# （2）遍历字典：结合key和value
for key, val in dict1.items():
    print("%s ==>> %s, type value: %s" % (key, val, type(val)))


